//
//  CYBaseTableViewCell.m
//  SafetyInHand
//
//  Created by admin on 2022/7/21.
//

#import "CYBaseTableViewCell.h"

@implementation CYBaseTableViewCell
+ (instancetype)cy_cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath {
    CYBaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.getIdentifier];
    if (!cell) {
        BOOL isHaveXib = nil != [[NSBundle mainBundle]pathForResource:NSStringFromClass([self class]) ofType:@"nib"];
        cell = (isHaveXib ? [self cell_loadFromNib] : [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:self.getIdentifier]) ? : [CYBaseTableViewCell new];
        [cell cellBaseSetConfig];
    }
    return cell;
}

+ (id)cell_loadFromNib {
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
}
+ (NSString *)getIdentifier {
    return [NSString stringWithFormat:@"CY_TB_%@", NSStringFromClass(self.class)];
}

/// cell的默认设置
- (void)cellBaseSetConfig {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor clearColor];
}
@end
